home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 4
/
Apprentice-Release4.iso
/
Source Code
/
Libraries
/
Graphic Elements 3
/
GEMisc
/
LGEPane.cp
< prev
next >
Wrap
Text File
|
1995-06-01
|
2KB
|
124 lines
// ===========================================================================
// LGEPane.cp ©1994 by Al Evans. All rights reserved.
// ===========================================================================
#include "LGEPane.h"
#include "GEWorldManager.h"
LGEPane* LGEPane::CreateLGEPaneStream(LStream *inStream)
{
return (new LGEPane(inStream));
}
LGEPane::LGEPane(LStream *inStream)
:LPane(inStream)
{
mGEWorld = nil;
mSubstitutePICT = 0;
mLoaded = false;
MakeWorld();
}
LGEPane::LGEPane()
:LPane()
{
mGEWorld = nil;
mSubstitutePICT = 0;
mLoaded = false;
}
LGEPane::LGEPane(const SPaneInfo &inPaneInfo, GEWorldLoader loadProc)
: LPane(inPaneInfo)
{
mGEWorld = nil;
mSubstitutePICT = 0;
mLoaded = false;
if (MakeWorld()) {
if (loadProc != nil)
LoadWorld(loadProc);
}
}
LGEPane::~LGEPane()
{
DisposeWorld();
}
Boolean LGEPane::MakeWorld()
{
Rect paneFrame;
DisposeWorld();
CalcPortFrameRect(paneFrame);
mGEWorld = NewGEWorld(GetMacPort(), &paneFrame, scaleOneToOne, nil);
if (mGEWorld != nil)
(void) AddToWorldList(mGEWorld, true);
return (mGEWorld != nil);
}
void LGEPane::DisposeWorld()
{
if (mGEWorld != nil) {
StopRepeating();
DisposeGEWorld(mGEWorld);
}
mGEWorld = nil;
}
Boolean LGEPane::LoadWorld(GEWorldLoader loadProc)
{
Boolean loaded;
if ((mGEWorld == nil) || (loadProc == nil))
loaded = false;
else
loaded = (loadProc)(mGEWorld);
if (loaded) {
ActivateWorld(mGEWorld, true);
StartRepeating();
}
mLoaded = loaded;
return loaded;
}
void LGEPane::SetSubstitutePICT(ResIDT pictResNum)
{
mSubstitutePICT = pictResNum;
}
GEWorldPtr LGEPane::GetGEWorld()
{
return mGEWorld;
}
void LGEPane::SpendTime(const EventRecord &inMacEvent)
{
if ((mGEWorld != nil) && mLoaded)
DoWorldUpdate(mGEWorld, false);
}
void LGEPane::DrawSelf()
{
if ((mGEWorld != nil) && mLoaded)
DoWorldUpdate(mGEWorld, true);
else
if (mSubstitutePICT != 0) {
PicHandle macPictureH = GetPicture(mSubstitutePICT);
if (macPictureH != nil) {
Rect pictureBounds = (**macPictureH).picFrame;
Rect paneFrame;
CalcPortFrameRect(paneFrame);
OffsetRect(&pictureBounds, paneFrame.left, paneFrame.top);
::DrawPicture(macPictureH, &pictureBounds);
}
}
}
void LGEPane::ClickSelf(const SMouseDownEvent &inMouseDown)
{
Boolean unused;
if (mGEWorld != nil)
unused = MouseDownInSensor(mGEWorld, inMouseDown.macEvent.where);
}